package com.qs.eggs.view.prodetail.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.backends.pipeline.PipelineDraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.common.ResizeOptions;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.qs.eggs.Constants;
import com.qs.eggs.R;
import com.qs.eggs.bean.EvaluationBean;
import com.qs.eggs.bean.ProPicBean;
import com.qs.eggs.refresh.adapter.BaseRecyclerAdapter;
import com.squareup.picasso.Picasso;


public class ProPicAdapter extends BaseRecyclerAdapter<ProPicBean> implements BaseRecyclerAdapter.OnLoadingHeaderCallBack {


    public ProPicAdapter(Context context, int mode) {
        super(context, mode);

        setOnLoadingHeaderCallBack(this);
    }

    @Override
    public RecyclerView.ViewHolder onCreateHeaderHolder(ViewGroup parent) {
        return new HeaderViewHolder(mHeaderView);
    }

    @Override
    public void onBindHeaderHolder(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new SortViewHolder(mInflater.inflate(R.layout.item_pro_pic, parent, false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, ProPicBean item, int position) {
        final SortViewHolder vh = (SortViewHolder) holder;

//        int width = 50, height = 50;
//        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
//                .setResizeOptions(new ResizeOptions(width, height))
//                .build();
//        PipelineDraweeController controller = Fresco.newDraweeControllerBuilder()
//                .setOldController(mDraweeView.getController())
//                .setImageRequest(request)
//                .build();
//        mSimpleDraweeView.setController(controller);

        String asd=Constants.URL_BASE+item.getFolder()+item.getAutoname();
     //   vh.mAvatar.setImageURI(Constants.URL_BASE+item.getFolder()+item.getAutoname());

        Picasso.with(mContext).load(asd).into(vh.mAvatar);
    }
    private static class SortViewHolder extends RecyclerView.ViewHolder {
        ImageView mAvatar;


        public SortViewHolder(View itemView) {
            super(itemView);
            mAvatar=(ImageView) itemView.findViewById(R.id.imageView);
        }
    }
}
